package ModelLayer;
import java.util.ArrayList;



public class EmployeeList
{
    
    private ArrayList<Employee> employees;
    private static EmployeeList instance;
   
    public EmployeeList()
    {
       employees = new ArrayList<Employee>();
    }
    
    public static EmployeeList getInstance()
    {
        if(instance == null)
        {
            instance = new EmployeeList();
        }
        return instance;
    }
    
    public void addEmployee (Employee newEmployee)
    {
        employees.add(newEmployee);
    }
    
     public void deleteUser(long userId)
    {
        Employee employee = findEmployee(userId);
        employees.remove(employee);
    }
    
    public Employee findEmployee(long userId)
    
    {
        boolean employeeFound = false;
        int index = 0;
        while(index < employees.size() && !employeeFound)
        {
            Employee s = employees.get(index);
            if(s.getEmployeeId() == userId)
            {
                employeeFound = true; 
            }
            else
            {
                index++;
            }
            
        }
        
        if(employeeFound)
        {
            return employees.get(index);
        }
        else
        {
            
            return null;
        }
      }
      }
    

